package wf.source.hrm.client;

import feign.hystrix.FallbackFactory;
import org.springframework.stereotype.Component;
import wf.source.hrm.util.AjaxResult;

import java.util.Map;

/**
 * 实现FallbackFactory接口 这是托底类
 */
@Component
public class RedisClientFallbackFactory implements FallbackFactory<RedisClient> {


    @Override
    public RedisClient create(Throwable throwable) {
        return new RedisClient() {
            @Override
            public AjaxResult add(Map<String, Object> params) {
                return AjaxResult.me().setSuccess(false).setMessage("托底数据，redis调用失败");
            }

            @Override
            public String get(String key) {
                return "redis调用失败";
            }

            @Override
            public AjaxResult del(String key) {
                return AjaxResult.me().setSuccess(false).setMessage("托底数据，redis调用失败");
            }
        };

    }
}
